<div class="row" style="margin-bottom: 10px;">
    <div class="col-sm-4">
        <div class="btn-group">
            <div class="btn-group" ng-if="user.level == 2 && user.role != 'financial' || user.level == 3 && user.role == 'leader'">
                <button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown">
                    审核
                    <span class="caret"></span>
                </button>
                <ul class="dropdown-menu" role="menu" ng-if="authority('view')">
                    <li>
                        <a href="javascript:void(0)" ng-click="review_state.change(3)">
                            <span class="glyphicon glyphicon-ok-circle" style="color: green" aria-hidden="true"></span> 初审通过
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)" ng-controller="modal_ctrl" ng-click="open_dialog(-3,'remark')">
                            <span class="glyphicon glyphicon-remove-circle" style="color: red" aria-hidden="true"></span> 初审拒绝
                        </a>
                    </li>
                </ul>
                <ul class="dropdown-menu" role="menu" ng-if="authority('review')">
                    <li>
                        <a href="javascript:void(0)" ng-click="review_state.change(4)">
                            <span class="glyphicon glyphicon-ok-circle" style="color: green" aria-hidden="true"></span> 复审通过
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)" ng-controller="modal_ctrl" ng-click="open_dialog(-4,'remark')">
                            <span class="glyphicon glyphicon-remove-circle" style="color: red" aria-hidden="true"></span> 复审拒绝
                        </a>
                    </li>
                </ul>
                <ul class="dropdown-menu" role="menu" ng-if="user.level == 3">
                    <li>
                        <a href="javascript:void(0)" ng-click="review_state.change(2)">
                            <span class="glyphicon glyphicon-ok-circle" style="color: green" aria-hidden="true"></span> 通过
                        </a>
                    </li>
                    <li>
                        <a href="javascript:void(0)" ng-controller="modal_ctrl" ng-click="open_dialog(-2,'remark')">
                            <span class="glyphicon glyphicon-remove-circle" style="color: red" aria-hidden="true"></span> 拒绝
                        </a>
                    </li>
                </ul>
            </div>
            <button type="button" class="btn btn-md btn-primary" ng-if="authority('add')" ng-controller="modal_ctrl"
                    ng-click="open_dialog('add')">
                新增
            </button>
            <button type="button" class="btn btn-md btn-primary" ng-if="authority('modify')" ng-controller="modal_ctrl"
                    ng-click="open_dialog('modify','gives')">
                修改
            </button>
            <button ng-if="user.level == 2" type="button" class="btn btn-md btn-success" ng-click="delete()">
                删除
            </button>
            <button ng-if="authority('push')" type="button" class="btn btn-md btn-primary" ng-click="review_state.change(5)">
                <span class="glyphicon glyphicon-usd" style="color: #ab3434" aria-hidden="true"></span> 推送
            </button>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-sm-4">
        <div class="input-group">
            <span class="input-group-addon">申请时间</span>
            <input type="text" class="form-control" ng-model="search.condition.apply_start" readonly
                   datepicker-popup="{{format}}" min-date="minDate" max-date="maxDate" datepicker-options="dateOptions"
                   date-disabled="disabled(date, mode)" ng-click="open($event)" is-open="write_time_opened"
                   current-text="今天" close-text="关闭" clear-text="清除" ng-controller="datepicker_ctrl">
            <span class="input-group-addon">至</span>
            <input type="text" class="form-control" ng-model="search.condition.apply_end" readonly
                   datepicker-popup="{{format}}" min-date="minDate" max-date="maxDate" datepicker-options="dateOptions"
                   date-disabled="disabled(date, mode)" ng-click="open($event)" is-open="write_time_opened"
                   current-text="今天" close-text="关闭" clear-text="清除" ng-controller="datepicker_ctrl">
        </div>
    </div>
    <div class="col-sm-2">
        <div class="input-group input-group-md">
            <span class="input-group-addon">证件号</span>
            <input type="text" class="form-control" ng-model="search.condition.salesman_card_id" />
        </div>
    </div>
    <div class="col-sm-2">
        <div class="input-group input-group-md">
            <span class="input-group-addon">工号</span>
            <input type="text" class="form-control" ng-model="search.condition.salesman_code" />
        </div>
    </div>
    <div class="col-sm-2">
        <div class="input-group input-group-md">
            <span class="input-group-addon">状态</span>
            <select class="form-control" ng-model="search.condition.review_state">
                <option value="">全部</option>
                <option value="normal">处理中...</option>
                <option value="6">代付成功</option>
                <option value="-6">代付失败</option>
            </select>
        </div>
    </div>
    <div class="col-sm-2">
        <div class="btn-group">
            <button type="button" class="btn btn-md btn-primary" ng-click="search.from_svr()">
                搜索
            </button>
            <button type="button" class="btn btn-md btn-success" ng-click="export()">
                导出
            </button>
        </div>
    </div>
</div>
<div class="jumbotron" style="padding: 10px;">
    <div class="row">
        <div class="col-sm-12">
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th rowspan="2" style="width: 32px;">
                            <input type="checkbox" name="checkbox" style="width: 15px; height: 15px;" ng-if="search.result.length > 0 && !search.has_repeated"
                                   ng-model="select.checked" ng-click="select.all()"/>
                        </th>
                        <th style="max-width: 47px;" rowspan="2">序号</th>
                        <th rowspan="2">管理机构</th>
                        <th rowspan="2">渠道</th>
                        <th colspan="6">销售人员信息</th>
                        <th colspan="3">销售人员银行账户信息</th>
                        <th rowspan="2">保证金<br>金额</th>
                        <th rowspan="2">退款<br>金额</th>
                        <th rowspan="2">备注</th>
                        <th rowspan="2">审核<br/>状态</th>
                        <th colspan="2">银行代扣信息</th>
                    </tr>
                    <tr>
                        <th>姓名</th>
                        <th>性别</th>
                        <th>证件类别</th>
                        <th>证件号</th>
                        <th>手机号</th>
                        <th>申请日期</th>
                        <th>账户名</th>
                        <th>账号</th>
                        <th>开户行</th>
                        <th>代付结果</th>
                        <th>处理时间</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="_this in search.result" ng-class="{error:_this.review_state == -6,success:_this.review_state == 6}" ng-click="select.one(_this)">
                        <td>
                            <input type="checkbox" name="checkbox" style="width: 15px; height: 15px;" ng-if="!search.has_repeated && show_check_box(_this)" ng-model="_this.checked"/>
                        </td>
                        <td>{{$index + 1}}</td>
                        <td>{{_this.agency_code}}</td>
                        <td>{{_this.channel}}</td>
                        <td>{{_this.salesman_name}}</td>
                        <td>{{_this.salesman_sex}}</td>
                        <td>{{_this.salesman_card_type}}</td>
                        <td>{{_this.salesman_card_id}}</td>
                        <td>{{_this.salesman_phone}}</td>
                        <td>{{_this.salesman_hiredate.split("T")[0]}}</td>
                        <td>{{_this.salesman_bank_account_name}}</td>
                        <td>{{_this.salesman_bank_account_number}}</td>
                        <td>{{_this.salesman_bank_name}}</td>
                        <td>￥{{_this.salesman_cash_deposit}}</td>
                        <td>￥{{_this.salesman_refunds}}</td>
                        <td>{{_this.remark}}</td>
                        <td title="{{review_state.name(_this.review_state)}}">
                            <span class="glyphicon glyphicon-remove" ng-if="search.has_repeated" style="color: red"></span>
                            <span class="glyphicon glyphicon-hourglass" ng-if="_this.review_state == 1" style="font-size: 19px;"></span>
                            <span class="glyphicon glyphicon-ok-circle" ng-if="_this.review_state == 2" style="font-size: 19px;"></span>
                            <span class="glyphicon glyphicon-remove-circle" ng-if="_this.review_state == -2" style="font-size: 19px;"></span>
                            <span class="glyphicon glyphicon-ok" ng-if="_this.review_state == 3" style="font-size: 19px;"></span>
                            <span class="glyphicon glyphicon-ban-circle" ng-if="_this.review_state == -3" style="font-size: 19px;"></span>
                            <span class="glyphicon glyphicon-option-horizontal" ng-if="_this.review_state == 4" style="font-size: 19px;"></span>
                            <span class="glyphicon glyphicon-option-horizontal" ng-if="_this.review_state == 5" style="font-size: 19px;"></span>
                            <span class="glyphicon glyphicon-file" ng-if="_this.review_state == 6" style="font-size: 19px;"></span>
                            <span class="glyphicon glyphicon-info-sign" ng-if="_this.review_state == -6" style="font-size: 19px;"></span>
                        </td>
                        <td>
                            {{_this.process_result}}
                        </td>
                        <td>
                            {{_this.finish_time.replace('T',' ')}}
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-5">
            <div class="form-group padding-0">
                <label class="col-sm-2 control-label" style="margin-top: 5px;">每页显示</label>
                <div class="col-sm-3">
                    <select ng-change="search.from_svr()" ng-model="page.size" class="form-control input-sm">
                        <option value="15">15</option>
                        <option value="25">25</option>
                        <option value="50">50</option>
                        <option value="100">100</option>
                    </select>
                </div>
                <label class="col-sm-4 control-label" style="margin-top: 5px;">条，共{{page.all_items.the_last()}}页 {{page.record_count}}条记录</label>
            </div>
        </div>
        <div class="col-sm-7 text-right">
            <ul class="pagination" style="margin: 0;">
                <li ng-click="page.turn_to(0)" ng-disabled="page.filtered.length == 1" class="paginate_button">
                    <a href="javascript:void(0)">第一页</a>
                </li>
                <li ng-click="page.turn_to(page.index - 1)" ng-disabled="page.filtered.length == 1"
                    class="paginate_button previous">
                    <a href="javascript:void(0)">&laquo;</a>
                </li>
                <li ng-repeat="item in page.filtered track by $index" ng-click="page.turn_to(item - 1)"
                    ng-class="{active: (page.index + 1) == item}" class="paginate_button">
                    <a href="javascript:void(0)">
                        {{item}}
                    </a>
                </li>
                <li ng-click="page.turn_to(page.index + 1)" ng-disabled="page.filtered.length == 1"
                    class="paginate_button next">
                    <a href="javascript:void(0)">&raquo;</a>
                </li>
                <li ng-click="page.turn_to(page.all_items.length - 1)" ng-disabled="page.filtered.length == 1"
                    class="paginate_button">
                    <a href="javascript:void(0)">最后一页</a>
                </li>
            </ul>
        </div>
    </div>
</div>